package com.czl.module_storehouse.activity.base;

import android.os.Bundle;
import android.view.LayoutInflater;

import androidx.annotation.CallSuper;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.czl.module_base.activity.BaseActivity;
import com.czl.module_storehouse.databinding.FooterCommonRemarkBinding;
import com.czl.module_storehouse.databinding.LayoutRecyclerViewBinding;

/**
 * @author by xubin,
 * @date on 2022/2/18.
 * PS: Not easy to write code, please indicate.
 */
public abstract class BaseDetailsActivity extends BaseActivity<LayoutRecyclerViewBinding> {

    protected FooterCommonRemarkBinding mFooterBinding;

    @Override
    protected LayoutRecyclerViewBinding getBinding(LayoutInflater layoutInflater) {
        return LayoutRecyclerViewBinding.inflate(layoutInflater);
    }

    @CallSuper
    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
        binding.recyclerView.setAdapter(getAdapter());
        mFooterBinding = FooterCommonRemarkBinding.inflate(getLayoutInflater());
        mFooterBinding.etRemark.setEnabled(false);
        getAdapter().addFooterView(mFooterBinding.getRoot());
    }

    /**
     * 获取adapter
     *
     * @return
     */
    protected abstract BaseQuickAdapter<?, ?> getAdapter();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (mFooterBinding != null) {
            mFooterBinding.unbind();
        }
    }
}
